import { axiosMock, delayFn, randArrItem } from '@/services/axiosMock'
import { INotice } from '../interface'

let count = 0

axiosMock('default', mock => {
  // 获取通知列表
  mock.onPost(`/tmsapi/customer_notice/list`).reply(
    delayFn<INotice[]>(600, () => {
      const idPrefix = ++count
      return {
        success: true,
        data: Array(randArrItem([10, 20, 30]))
          .fill(null)
          .map((_item, index) => {
            const id = +`${idPrefix}${index + 1}`
            return {
              noticeId: id,
              routeId: id,
              logisticsStatus: randArrItem([0, 1, 2, 3, 4, 5, 6], 0.1),
              routeNode: randArrItem([0, 1, 2, 3, 4, 5, 6, 7, 8], 0.1),
              routeTitle: `已通过拖车运输，待抵达港口${id}`,
              occurDate: randArrItem(['2023-11-16 12:12:12', '2024-11-16 12:12:12'], 0.1),
              noticeStatus: randArrItem([0, 1, 2], 0.1),
              noticeDate: randArrItem(['2023-11-16 12:12:12', '2024-11-16 12:12:12'], 0.1),
            } satisfies INotice
          }),
      }
    }),
  )

  // 取消通知
  mock.onPost(`/tmsapi/customer_notice/cancelNotice`).reply(
    delayFn(600, () => {
      return {
        success: true,
      }
    }),
  )
})
